#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   start_app.py
@Time    :   2024-07-09 12:54:26
@Author  :   chakcy 
@Email   :   947105045@qq.com
@description   :   fastapi启动方法
'''

import uvicorn
from fastapi import FastAPI

from ..config import config


def startApp(app: FastAPI):
    print("                            启动！！！！")
    print()
    print("                            _ooOoo_               ")
    print("                           o8888888o               ")
    print("                           88  .  88              ")
    print("                           (| -_- |)                   ")
    print("                            O\\ = /O                    ")
    print("                        ____/`---'\\____               ")
    print("                      .   ' \\| |// `.             ")
    print("                       / \\||| : |||// \\          ")
    print("                     / _||||| -:- |||||- \\          ")
    print("                       | | \\\\\\ - /// | |            ")
    print("                     | \\_| ''\\---/'' | |           ")
    print("                      \\ .-\\__ `-` ___/-. /           ")
    print("                   ___`. .' /--.--\\ `. . __            ")
    print("                ."" '< `.___\\_<|>_/___.' >'"".         ")
    print("               | | : `- \\`.;`\\ _ /`;.`/ - ` : | |     ")
    print("                 \\ \\ `-. \\_ __\\ /__ _/ .-` / /     ")
    print("         ======`-.____`-.___\\_____/___.-`____.-'======  ")
    print("                            `=---='  ")
    print("  ")
    print("         ......................阿弥陀佛.......................  ")

    """启动fastapi服务"""
    if config.reload == True:
        uvicorn.run("app:app", host=config.host, port=config.port, reload=True)
    else:
        uvicorn.run(app, workers=config.workers, host=config.host, port=config.port)
